package GUI;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class LoginPanel extends javax.swing.JPanel {

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	private JTextField jTextFieldBenutzername;
	private JButton jButtonAbbrechen;
	private JButton jButtonLogIn;
	private JTextField jTextFieldPassword;
	private JTextField jTextField1;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
//				LoginPanel inst = new LoginPanel();
//				inst.setLocationRelativeTo(null);
//				inst.setVisible(true);
				
				JFrame frame = new JFrame();
				frame.getContentPane().add(new LoginPanel());
				frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
				frame.pack();
				frame.setVisible(true);
			}
		});
	}
	
	public LoginPanel() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
//			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setLayout(null);
			{
				jTextFieldBenutzername = new JTextField();
				this.add(jTextFieldBenutzername);
				jTextFieldBenutzername.setText("Benutzername eingeben");
				jTextFieldBenutzername.setBounds(165, 59, 176, 31);
				jTextFieldBenutzername.addFocusListener(new FocusAdapter() {
					public void focusLost(FocusEvent evt) {
						jTextFieldBenutzernameFocusLost(evt);
					}
					public void focusGained(FocusEvent evt) {
						jTextFieldBenutzernameFocusGained(evt);
					}
				});
			}
			{
				jButtonAbbrechen = new JButton();
				this.add(jButtonAbbrechen);
				jButtonAbbrechen.setText("Abbrechen");
				jButtonAbbrechen.setBounds(235, 184, 106, 22);
				jButtonAbbrechen.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						jButtonAbbrechenActionPerformed(evt);
					}
				});
			}
			{
				jButtonLogIn = new JButton();
				this.add(jButtonLogIn);
				jButtonLogIn.setText("Login");
				jButtonLogIn.setBounds(125, 184, 80, 22);
				jButtonLogIn.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						jButtonLogInActionPerformed(evt);
					}
				});
			}
			{
				jTextFieldPassword = new JTextField();
				this.add(jTextFieldPassword);
				jTextFieldPassword.setText("Kennwort eingeben");
				jTextFieldPassword.setBounds(165, 111, 176, 28);
				jTextFieldPassword.addFocusListener(new FocusAdapter() {
					public void focusLost(FocusEvent evt) {
						jTextFieldPasswordFocusLost(evt);
					}
					public void focusGained(FocusEvent evt) {
						jTextFieldPasswordFocusGained(evt);
					}
				});

			}
			{
				jTextField1 = new JTextField();
				this.add(jTextField1);
				jTextField1.setText("jTextField1");
				jTextField1.setBounds(-16, 0, -79, 22);
			}
			setSize(400, 300);
			this.setBackground(new java.awt.Color(238,238,238));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void jTextFieldBenutzernameFocusGained(FocusEvent evt) {
			
		jTextFieldBenutzername.setText("");
	}
	
	private void jTextFieldBenutzernameFocusLost(FocusEvent evt) {
		if(jTextFieldBenutzername.getText().equals(""))
			jTextFieldBenutzername.setText("Benutzername eingeben");
	}
	
	private void jTextFieldPasswordFocusGained(FocusEvent evt) {
		jTextFieldPassword.setText("");
		
	}
	
	private void jTextFieldPasswordFocusLost(FocusEvent evt) {
		
		if(jTextFieldPassword.getText().equals(""))
			jTextFieldPassword.setText("Kennwort eingeben");
	}
	
	private void jButtonAbbrechenActionPerformed(ActionEvent evt) {
		System.exit(0);

	}
	
	private void jButtonLogInActionPerformed(ActionEvent evt) {
//		String x = jTextFieldBenutzername.getText();
//		String y = jTextFieldPassword.getText();
//		if(
//				);
	}

}
